/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "MARKER")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Marker.findAll", query = "SELECT m FROM Marker m"),
    @NamedQuery(name = "Marker.findByIdMarker", query = "SELECT m FROM Marker m WHERE m.markerPK.idMarker = :idMarker"),
    @NamedQuery(name = "Marker.findByIdPersonalInfo", query = "SELECT m FROM Marker m WHERE m.markerPK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "Marker.findByIdBranchenterprise1", query = "SELECT m FROM Marker m WHERE m.markerPK.idBranchenterprise1 = :idBranchenterprise1"),
    @NamedQuery(name = "Marker.findByIdEnterprise1", query = "SELECT m FROM Marker m WHERE m.markerPK.idEnterprise1 = :idEnterprise1")})
public class Marker implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected MarkerPK markerPK;
    @JoinColumn(name = "ID_ROUTE", referencedColumnName = "ID_ROUTE")
    @OneToOne(fetch = FetchType.LAZY)
    private Route idRoute;
    @JoinColumns({
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE1", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE1", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private PersonalInfo personalInfo;

    public Marker() {
    }

    public Marker(MarkerPK markerPK, Route route) {
        this.markerPK = markerPK;
        this.idRoute=route;
    }

    public Marker(BigInteger idMarker, BigInteger idPersonalInfo, BigInteger idBranchenterprise1, BigInteger idEnterprise1) {
        this.markerPK = new MarkerPK(idMarker, idPersonalInfo, idBranchenterprise1, idEnterprise1);
    }

    public MarkerPK getMarkerPK() {
        return markerPK;
    }

    public void setMarkerPK(MarkerPK markerPK) {
        this.markerPK = markerPK;
    }

    public Route getIdRoute() {
        return idRoute;
    }

    public void setIdRoute(Route idRoute) {
        this.idRoute = idRoute;
    }

    public PersonalInfo getPersonalInfo() {
        return personalInfo;
    }

    public void setPersonalInfo(PersonalInfo personalInfo) {
        this.personalInfo = personalInfo;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (markerPK != null ? markerPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Marker)) {
            return false;
        }
        Marker other = (Marker) object;
        if ((this.markerPK == null && other.markerPK != null) || (this.markerPK != null && !this.markerPK.equals(other.markerPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.Marker[ markerPK=" + markerPK + " ]";
    }
    
}
